package com.yogee.topseller.fragment.productdetail;

import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yogee.core.base.HttpFragment;
import com.yogee.topseller.R;
import com.yogee.topseller.bean.ProductInfoBean;
import com.yogee.topseller.view.MyScrollView;
import com.yogee.topseller.view.PublicStaticClass;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by zwj on 2017/12/7.
 */

public class AccountFragment extends BaseFragment {
    @BindView(R.id.tv_account)
    TextView tv_account;
    @BindView(R.id.oneScrollview)
    MyScrollView oneScrollView;
    @BindView(R.id.ll_nodata)
    LinearLayout ll_nodatal;
    Unbinder unbinder1;

    private ProductInfoBean beans;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_product_acount;
    }

    @Override
    protected void initView() {
        beans = (ProductInfoBean) getArguments().getSerializable("baseInfo");
        if(beans.getAccount()!=null&&beans.getAccount().size()>0){
            if(beans.getAccount().get(0).getRemark().equals("")||beans.getAccount().get(0).getRemark().equals("通过产品咨询获取更多详细信息")){
                tv_account.setVisibility(View.GONE);
                ll_nodatal.setVisibility(View.VISIBLE);
            }else{
                tv_account.setText(Html.fromHtml(beans.getAccount().get(0).getRemark()));
                tv_account.setVisibility(View.VISIBLE);
                ll_nodatal.setVisibility(View.GONE);
            }

        }else{
            tv_account.setVisibility(View.GONE);
            ll_nodatal.setVisibility(View.VISIBLE);
        }

        oneScrollView.setScrollListener(new MyScrollView.ScrollListener() {
            @Override
            public void onScrollToBottom() {

            }

            @Override
            public void onScrollToTop() {

            }

            @Override
            public void onScroll(int scrollY) {
                if (scrollY == 0) {
                    PublicStaticClass.IsTop = true;
                } else {
                    PublicStaticClass.IsTop = false;
                }
            }

            @Override
            public void notBottom() {

            }

        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder1 = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder1.unbind();
    }

    @Override
    public String getTitle() {
        return "募集账号";
    }
}
